<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xml:lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml" lang="zh-CN">
<%@ include file="../common/_new_head.jsp" %>
<!--积分弹出层 -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="exampleModalLabel">发放积分</h4>
            </div>
            <form action="/battle/score">
                <div class="modal-body">
                    <input type="hidden" name="battleId" id="battle_id"/>
                    <input type="hidden" name="matchId" id="match_id"/>
                    <div class="form-group">
                        <label for="recipient-name" class="control-label">积分:</label>
                        <input type="text" class="form-control" name = "score" id="recipient-name">
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button type="submit" class="btn btn-primary">确定</button>
                </div>
            </form>
        </div>
    </div>
</div>

<!--积分弹出层-->
<div class="content-wrapper">
    <!-- Main content -->
    <section class="content">
        <c:forEach items="${battles}" var="battleList" varStatus="xh">
        <div class="row">
            <div class="col-sm-12">
                <div class="box">
                <div class="box-header">
                    <h3 class="box-title">第${count-xh.count+1}轮</h3>
                </div>

                <div class="box-body table-responsive">
                    <table class="table table-striped">
                        <tbody>
                        <c:forEach items="${battleList}" var="battle">
                            <tr>
                                <td style="width: 8%;">${battle.vo1.groupNo}</td>
                                <td style="width: 25%;">
                                    <c:if test="${battle.vo1.state=='胜利'}">
                                        <img src="/img/win.png" style="width: 40px"/>
                                    </c:if>
                                    ${battle.vo1.signName}
                                    <c:if test="${battle.vo1.score!=null}">
                                    <b>积${battle.vo1.score}分</b>
                                    </c:if>
                                </td>
                                <td style="width: 15%;">
                                    <c:if test="${ sessionScope.level>'0'&&battle.vo1.state=='准备中'}">
                                        <a href="/battle/getVictory/${battle.vo1.id}-${battle.vo1.groupNo}-${battle.vo1.matchId}-${battle.vo2.id}">获胜</a>
                                        | <a href="/battle/goBackUp/${battle.vo1.id}-${battle.vo1.groupNo}-${battle.vo1.matchId}">替补</a>
                                    </c:if>
                                    <c:if test="${ sessionScope.level>'0'&&battle.vo1.state=='胜利'}">
                                        <button type="button" class="btn btn-block btn-success btn-xs" data-whatever="${battle.vo1.id}" data-toggle="modal" data-target="#exampleModal" >积分</button>
                                    </c:if>
                                    <c:if test="${ sessionScope.level>'0'&&battle.vo1.state=='失败'}">
                                        <a href="/battle/correctMistake/${battle.vo1.id}-${battle.vo1.groupNo}-${battle.vo1.matchId}-${battle.vo2.id}">判错</a>
                                    </c:if>
                                </td>
                                <td style="width: 3%;">vs</td>
                                <td style="width: 25%;">
                                    <c:if test="${battle.vo2.state=='胜利'}">
                                        <img src="/img/win.png" style="width: 40px"/>
                                    </c:if>
                                    ${battle.vo2.signName}
                                    <c:if test="${battle.vo2.score!=null}">
                                        <b>积${battle.vo2.score}分</b>
                                    </c:if>
                                </td>
                                <td style="width: 15%;">
                                    <c:if test="${ sessionScope.level>'0'&&battle.vo2.state=='准备中'}">
                                        <a href="/battle/getVictory/${battle.vo2.id}-${battle.vo2.groupNo}-${battle.vo2.matchId}-${battle.vo1.id}">获胜</a>
                                        | <a
                                            href="/battle/goBackUp/${battle.vo2.id}-${battle.vo2.groupNo}-${battle.vo2.matchId}">替补</a>
                                    </c:if>
                                    <c:if test="${ sessionScope.level>'0'&&battle.vo2.state=='胜利'}">
                                        <button type="button" class="btn btn-block btn-success btn-xs" data-whatever="${battle.vo2.id}" data-toggle="modal" data-target="#exampleModal" >积分</button>
                                    </c:if>
                                    <c:if test="${ sessionScope.level>'0'&&battle.vo2.state=='失败'}">
                                        <a href="/battle/correctMistake/${battle.vo2.id}-${battle.vo2.groupNo}-${battle.vo2.matchId}-${battle.vo1.id}">判错</a>
                                    </c:if>
                                </td>
                                <td style="width: 8%;">${battle.vo2.groupNo}</td>
                            </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
                </div>
            </div>
            <!--/.col (right) -->
        </div>
        <!-- /.row -->
        </c:forEach>
    </section>
    <!-- /.content -->
</div>
<%@ include file="../common/_new_foot.jsp" %>
<script type="text/javascript">

    $('#exampleModal').on('show.bs.modal', function (event) {
        var button = $(event.relatedTarget);
        var recipient = button.data('whatever');
        var modal = $(this);
        modal.find('#battle_id').val(recipient);
    })
</script>
</html>
